package com.example.ioc.mapper.impl;

import com.example.ioc.mapper.AccountMapper;
import com.example.ioc.pojo.Account;
import com.example.ioc.util.SqlSession;
import com.example.spring.framework.annotation.Mapper;

/**
 * @author admin
 * @Date 2021/1/4 23:16
 * @Description TODO
 */
@Mapper
public class AccountMapperImpl implements AccountMapper {

    @Override
    public Account queryAccountByCardNo(String cardNo) throws Exception {
        Account account = new Account();
        account.setCardNo(cardNo);
        account = (Account) new SqlSession().selectOne(account);
        return account;
    }

    @Override
    public int updateAccountByCardNo(Account account) throws Exception {
        StringBuffer sql = new StringBuffer("update account set ");
        sql = sql.append(" money = ").append(account.getMoney());
        sql = sql.append(" where cardNo = ").append(account.getCardNo());
        System.out.println("sql:" + sql.toString());

        return new SqlSession().update(sql.toString());
    }


}
